package com.example.demo.controller;

import com.example.demo.vo.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author shenb
 * @date 2022-06-28 13:45
 */
@Controller
public class IndexController {

    @RequestMapping
    public ModelAndView index() {
        return new ModelAndView("index", "name", "world");
    }

    @RequestMapping("test")
    public ModelAndView error() {
        throw new IllegalArgumentException("this is error");
    }

    @ResponseBody
    @RequestMapping("test2")
    public Result<Void> json() {
        throw new IllegalArgumentException("json error");
    }
}
